package main

import (
	"fmt"
	"time"
)

func getRecentDateList(now time.Time, weekdayList []int) (res []string) {
	res = []string{}
	curWeekDay := int(now.Weekday())
	if curWeekDay == 0 {
		curWeekDay = 7
	}
	initWeekDay := 0
	var selectedDay time.Time
	for _, v := range weekdayList {
		if v >= curWeekDay {
			initWeekDay = v
			selectedDay = now.AddDate(0, 0, v-curWeekDay)
			res = append(res, selectedDay.Format("2006-01-02"))
		}
	}
	if len(res) <= 1 {
		initWeekDay = weekdayList[0]
		selectedDay = now.AddDate(0, 0, 7-(curWeekDay-initWeekDay))
		res = append(res, selectedDay.Format("2006-01-02"))
	}
	return

}

func main() {
	weekdayList := []int{1, 2, 4}
	fmt.Println(getRecentDateList(time.Now(), weekdayList))
}
